# Importing Data
US <- read_excel("C:/Users/Biniam/Desktop/Documents/Academic/Thesis/Analysis Folder/Excel Files/Steel/TSA.xlsx",sheet = "Sheet1", range = "AN1:AN239")

# Checking the Imported Data
View(US)
# Creating Time Series Data
US_ts <- ts(US, start=c(2000,1), end=c(2019,09), frequency=12)
# Viewing and Checking the Created Time Series Data
US_ts
sum(is.na(US_ts))
library(forecast)
US_ts <- tsclean(US_ts)
US_ts

# Identification: Plotting the Time Series Data
plot(US_ts)

# Estimating the appropriate model
US_ts_model <- auto.arima(US_ts)
US_ts_model

# Forecasting
options(max.print=1000000)
US_ts_forecast <- forecast (US_ts_model, level=c(95), h=255)
plot(US_ts_forecast)
US_ts_forecast             

# Exporting
write.table(US_ts_forecast, file="/Users/Biniam/Desktop/Documents/Academic/Thesis/Result Folder/TSA Results/Excel Files/From R/Steel/US_TSA.csv", sep=",")
